package com.vastcom.action;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.opensymphony.xwork2.ActionSupport;




@Results({ 
	@Result(name = "json", location = "/jsonData.jsp"),
			@Result(name = "errorException", location = "/errorMSG.jsp"),
	@Result(name = "error", location = "/error.jsp") })
public class BaseAction extends ActionSupport {
	
	
	private static final long serialVersionUID = 1L;

	protected HttpServletRequest request = ServletActionContext.getRequest();
	/**
	 * HttpServletResponse
	 */
	protected HttpServletResponse response = ServletActionContext.getResponse();
	/**
	 * HttpSession
	 */
	protected HttpSession session = request.getSession();
  
    
	
	
	


	private String myfileFileName;
	
	protected JSONObject json =new JSONObject();
	
	protected JSONArray jsonArray=new JSONArray();
	

	public String getMyfileFileName() {
		return myfileFileName;
	}

	public void setMyfileFileName(String myfileFileName) {
		this.myfileFileName = myfileFileName;
	}

	/**
	 * json
	 */
	
	private String jsonString;

	public String getJsonString() {
		return jsonString;
	}

	public void setJsonString(String jsonString) {
		this.jsonString = jsonString;
	}

	public void outJsonString() {
		try {
			response.setHeader("Cache-Control", "no-cache");
			response.setContentType("text/json;charset=UTF-8");
			response.getWriter().write(this.jsonString);
			response.getWriter().flush();
			response.getWriter().close();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
	

	public void outJsonString(String jsonString) {
		try {
			this.jsonString = jsonString;
			this.outJsonString();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
	

}
